﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace DevAwesome.WebDataBridge.StorageProviders {

    public class Default : IWebDataBridgeStorageProvider {
        Dictionary<string, object> data = new Dictionary<string, object>( );
        #region IWebDataBridgeStorageProvider Members

        public bool Exists( string endPoint ) {
            return data.Keys.Contains( endPoint );
        }

        public T Read<T>( string endPoint ) where T : class {
            T obj = data[ endPoint ] as T;
            return obj;
        }

        public void Update( string endpoint, object obj ) {
            if( !Exists( endpoint ) )
                data.Add( endpoint, obj );
            else
                data[ endpoint ] = obj;
        }

        #endregion
    }
}
